FROM crpi-8vcd3lhq66d7ntyj.cn-guangzhou.personal.cr.aliyuncs.com/opencj/ubuntu:opencj-0.59.6 as cj_build
WORKDIR /build

COPY . .
RUN rm cjpm.toml
RUN cp cjpm.linux.toml cjpm.toml
ENV CANGJIE_HOME=/opt/cangjie
ENV LD_LIBRARY_PATH=/opt/cangjie/runtime/lib/linux_x86_64_llvm:/opt/cangjie/tools/lib:
ENV PATH=/opt/cangjie/bin:/opt/cangjie/tools/bin:/opt/cangjie/bin:/opt/cangjie/tools/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.cjpm/bin
ENV OLDPWD=/root/.cjpm
RUN apt-get install git libstdc++-10-dev  -y
RUN mkdir -p /root/.cjpm/bin
RUN cjpm clean && cjpm update && cjpm build -o app

# FROM crpi-8vcd3lhq66d7ntyj.cn-guangzhou.personal.cr.aliyuncs.com/opencj/ubuntu:20.04
FROM crpi-8vcd3lhq66d7ntyj.cn-guangzhou.personal.cr.aliyuncs.com/opencj/ubuntu:openssl-3.0.7
#FROM crpi-8vcd3lhq66d7ntyj.cn-guangzhou.personal.cr.aliyuncs.com/opencj/ubuntu:opencj-0.59.6-v2
WORKDIR /opt/official-backend
COPY resources /opt/official-backend/resources
COPY --from=cj_build /build/target/release/bin/app /opt/official-backend/app
EXPOSE 8080

ENTRYPOINT [ "/opt/official-backend/app" ]